package com.example.practical_training_projects.mapper;

import com.example.practical_training_projects.entity.collect_articles;
import com.example.practical_training_projects.vo.vousercollectarticles;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface collect_articlesMapper {
    @Insert("INSERT INTO collect_articles (a_uid,user_uid,create1_time) VALUES (#{a_uid},#{user_uid},sysdate())")
    Integer insertcollect(@Param("a_uid") Integer a_uid, @Param("user_uid")Integer user_uid);

    @Select("SELECT * FROM collect_articles where a_uid = #{a_uid} and user_uid = #{user_uid}")
    collect_articles checkcollect(@Param("a_uid") Integer a_uid, @Param("user_uid")Integer user_uid);

    @Delete("DELETE FROM collect_articles where a_uid =#{a_uid} and user_uid = #{user_uid}")
    Integer deletecollect(@Param("a_uid") Integer a_uid, @Param("user_uid")Integer user_uid);

    @Select("select articles.*,collect_articles.* from collect_articles join articles  on collect_articles.a_uid = articles.a_uid where collect_articles.user_uid=#{user_uid}\n" +
            "order by collect_articles.create1_time ")
    List<vousercollectarticles> findusercollectarticles(@Param("user_uid") Integer user_uid);

}
